x86/p2m-pt: simplify p2m_next_level()
authorJan Beulich <jbeulich@suse.com>
Mon, 4 Sep 2017 14:25:59 +0000 (16:25 +0200)
committerJan Beulich <jbeulich@suse.com>
Mon, 4 Sep 2017 14:25:59 +0000 (16:25 +0200)
commit9f2e25c0042312071935047a93144914f969575f
tree00475522500db34197292e83598a4603af9ac644
parent0cfcbe6c2a08b12a15cbccdcb9b3cdb24d77d6cd
x86/p2m-pt: simplify p2m_next_level()

Calculate entry PFN and flags just once. Convert the two successive
main if()-s to and if/else-if chain. Restrict variable scope where
reasonable. Take the opportunity and also make the induction variable
unsigned.

This at once fixes excessive permissions granted in the 2M PTEs
resulting from splitting a 1G one - original permissions should be
inherited instead. This is not a security issue only because all of
this takes no effect anyway, as iommu_hap_pt_share is always false on
AMD systems for all supported branches.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: George Dunlap <george.dunlap@citrix.com>
xen/arch/x86/mm/p2m-pt.c